package game.actions;

import edu.monash.fit2099.engine.actions.Action;
import edu.monash.fit2099.engine.actors.Actor;
import edu.monash.fit2099.engine.positions.GameMap;
import game.actors.Player;
import game.items.Bottle;

/**
 * Action to drink from a bottle.
 */
public class DrinkAction extends Action {

    private final Bottle bottle;

    public DrinkAction(Bottle bottle) {
        this.bottle = bottle;
    }

    @Override
    public String execute(Actor actor, GameMap map) {
        if (!(actor instanceof Player)) {
            return actor + " cannot drink.";
        }
        Player p = (Player) actor;
        if (!bottle.hasCharge()) {
            return "The bottle is empty.";
        }
        bottle.consumeCharge();
        p.addHydration(4);
        return actor + " drinks from the bottle (+4 Hydration; "
                + "Hydration=" + p.getHydration() + "/" + p.getMaxHydration() + ").";
    }

    @Override
    public String menuDescription(Actor actor) {
        return "Drink from bottle";
    }
}
